#include "editor.h"

Editor::Editor(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), this, SLOT(OnIdle()));
	timer->start(0);

	d3dWidget = new D3DWidget(this);
	d3dWidget->setFixedWidth(800);
	d3dWidget->setFixedHeight(600);

	QBoxLayout * layout = new QBoxLayout(QBoxLayout::Direction::LeftToRight);
	layout->addWidget(d3dWidget);
	ui.centralWidget->setLayout(layout);

	this->adjustSize();

	GD::_ED.hWnd = (HWND)d3dWidget->winId();
	GD::_ED.lpCmdLine = "";
	GD::_ED.nCmdShow = 0;
	GD::_ED.windowWidth = d3dWidget->width();
	GD::_ED.windowHeight = d3dWidget->height();

	Engine::Instance().Start();

}

Editor::~Editor()
{
	Engine::Instance().Shutdown();
}

void Editor::OnIdle()
{
	Engine::Instance().Update();

	int u = d3dWidget->width();

}